<template>
    <div class="ma-content-block  p-4 flex " style='flex-direction: column;height:calc(100vh - 112px);'>
        <!-- <div class="flex justify-between home-page-title " style="margin-bottom:2%">
            <div style="text-align:center;padding:0 16px 0 14px">时间选择</div>
            <div class="ma-content-block rounded-sm flex justify-between w-full " style="flex:1;width:0">
                <div class="datetime  flex">
                  <template  v-for="(item, index) in tags"
                      :key="index">
                    <span
                      v-if='item.show'
                      @click="changeTime(index)"
                      :class="{ active: index == currentTag }"
                    >
                    {{ item.name }}
                      
                    </span>
                  </template>
                <a-range-picker
                    style="width: 268px"
                    v-model="currentTime"
                    @change="onChange"
                >
                    <span
                    @click="changeTime(tags.length)"
                    :class="{ active: currentTag == tags.length }"
                    >
                    自定义
                    </span>
                </a-range-picker>
                </div>
            </div>
        </div> -->
        <div class="flex " style="margin-bottom:1.5%;align-items: center;">
            <div style="text-align:center;padding:0 16px 0 14px">支付方式</div>
            <a-select :style="{width:'420px'}"  :options="zffsArr" v-model="zffs" placeholder="请选择支付方式" allow-clear @change="handleChange">
            </a-select>
        </div>
        <div class="flex " style="margin-bottom:1.5%;align-items: center;">
            <div style="text-align:center;padding:0 16px 0 14px">分账状态</div>
            <a-space direction="vertical" size="large">
                <a-radio-group v-model="fzzt" :options="optionsfzzt" @change="handleRadioChange">
                <template #label="{ data }">
                    <div>{{ data.label }}</div>
                </template>
                </a-radio-group>
            </a-space>
        </div>
        
      <!-- CRUD 组件 -->
      <div class='flex_1' ref='boxRef'>
        <ma-crud :options="options" :columns="columns" ref="crudRef" @selection-change="setSelectedKeys" :selected-keys="ids">
          <template #tableBeforeButtons>
              <a-button type="primary" @click="handleShowJiesuan">结算</a-button>
              <a-button type="primary" @click='handleExport'>结算表查询</a-button>
          </template>

          <template #pay_real_price="{ record }">
            <a-popover :title="`费用明细（合计金额：${record.pay_real_price}）`" position="right">
                <a-link >{{record?.pay_real_price}}</a-link>
                <template #content>
                  <div style='min-width:300px'>
                    <a-table :columns="tablecolumnsts" :data="record.detail" :pagination='false' :span-method="spanMethodAll" :bordered="{wrapper: true, cell: true}"/>
                  </div>
                </template>
            </a-popover>
          </template>
          <template #dept_id="{ record }">
              <div>{{ record?.dept?.name}}</div>
          </template>
          <template #pay_type="{ record }">
              <div>{{ record.pay_type=='money'?'预付款':record.pay_type=='periodic'?'周期结算':'现结' }}</div>
          </template>
          <template #now_pay_type="{ record }">
              <div>{{ record.now_pay_type=='1'?'惠支付':record.now_pay_type=='2'?'现金':record.now_pay_type=='3'?'对公转账':'' }}</div>
          </template>
        </ma-crud>
      </div>
      <div class='lg:flex'>
        <div style='width:300px'>小计：{{xiaoji.toFixed(2)}}</div>
        <div>合计：{{heji}}</div>
      </div>
      <!-- 结算弹窗 -->
      <a-modal :mask-closable="false"  v-model:visible="showJiesuan" v-if="showJiesuan" title="结算" @cancel="handleYujiCel" :width="1400" ok-text='确认结算' :on-before-ok='handleQuerenJS'>
        <div style="font-size: 18px;margin-bottom: 1%;">结算信息：</div>
        <a-form :model="rowData" >
            <a-row :gutter="16">
                <a-col :span="6">
                    <a-form-item field="qsgs" label="付款方" label-col-flex="80px">
                        <a-select :options="qsgsArr" v-model="rowData.qsgs" placeholder="请选择付款方" allow-clear @change="handleChangeqsgs"></a-select>
                    </a-form-item>
                </a-col>
                <a-col :span="6">
                    <a-form-item field="skf" label="收款方" label-col-flex="80px">
                        <a-select :options="skfArr" v-model="rowData.skf" placeholder="请选择收款方" allow-clear @change="handleChangeskf"></a-select>
                    </a-form-item>
                </a-col>
                <a-col :span="6">
                    <a-form-item field="jsbl" label="结算比例" label-col-flex="80px">
                        <a-input  v-model="rowData.jsbl" placeholder="请输入结算比例" allow-clear >
                            <template #suffix>
                                <div>%</div>
                            </template>
                        </a-input>
                    </a-form-item>
                </a-col>
                <a-col :span="6">
                    <a-form-item  label="业务所属月份" label-col-flex="80px">
                      <a-month-picker  style="width: 200px;" @change='handleMonth' />
                    </a-form-item>
                </a-col>
            </a-row>
            <a-row :gutter="16">
                <a-col :span="24">
                    <a-form-item field="beizhu" label="备注" label-col-flex="80px">
                        <a-textarea v-model="rowData.beizhu" placeholder="请输入备注" allow-clear/>
                    </a-form-item>
                </a-col>
            </a-row>
        </a-form>
        <!-- <ma-crud :options="optionses"  :columns="columnses" ref="crudRefs" @selection-change="setSelectedmodleKeys" :selected-keys="ids">
            <template #pay_price="{ record }">
              <a-popover title="费用明细" position="right">
                  <a-link >{{record?.pay_price}}<icon-link /></a-link>
                  <template #content>
                    <div style='min-width:300px'>
                      <a-table :columns="tablecolumnsts" :data="record.detail" />
                    </div>
                  </template>
              </a-popover>
            </template>
            <template #pay_type="{ record }">
                <div>{{ record.pay_type=='money'?'预付款':record.pay_type=='periodic'?'周期结算':'线上支付' }}</div>
            </template>
            <template #dept_id="{ record }">
                <div>{{ record?.dept?.name}}</div>
            </template>
            <template #now_pay_type="{ record }">
                <div>{{ record.now_pay_type=='1'?'微信支付':record.now_pay_type=='2'?'支付宝支付':record.now_pay_type=='3'?'对公转账':'' }}</div>
            </template>
        </ma-crud> -->
        <!--  @selection-change='setSelectedmodleKeys' v-model:selectedKeys='ids' -->
        <a-table :columns="columnses" :data="jiesuandata" row-key='id' @selection-change='setSelectedmodleKeys' v-model:selectedKeys='ids' 
          :row-selection="{
            type: 'checkbox',
            showCheckedAll: true,
            onlyCurrent: false,
          }" 
          :virtual-list-props="{height:400}" :pagination="false" >
            <template #pay_price="{ record }">
              <a-popover :title="`费用明细（合计金额：${record.pay_price}）`" position="right">
                  <a-link >{{record?.pay_price}}</a-link>
                  <template #content>
                    <div style='min-width:300px'>
                      <a-table :columns="tablecolumnsts" :data="record.detail" />
                    </div>
                  </template>
              </a-popover>
            </template>
            <template #pay_type="{ record }">
                <div>{{ record.pay_type=='money'?'预付款':record.pay_type=='periodic'?'周期结算':'现结' }}</div>
            </template>
            <template #dept_id="{ record }">
                <div>{{ record?.dept?.name}}</div>
            </template>
            <template #now_pay_type="{ record }">
                <div>{{ record.now_pay_type=='1'?'惠支付':record.now_pay_type=='2'?'现金':record.now_pay_type=='3'?'对公转账':'' }}</div>
            </template>
        
        </a-table>
        <div class='lg:flex' style='margin-top:2%'>
          <div style='width:300px'>已选择金额合计：{{showMxiaojia.toFixed(2)}}</div>
        </div>
      </a-modal>

      <!-- 预览结算表格 -->
      <a-modal :mask-closable="false"  v-model:visible="showPreview" v-if="showPreview" title="结算表预览" @cancel="handlePreviewCel" :width="1400" :footer="false" >
        <preview></preview>
      </a-modal>
    </div>
  </template>
  <script setup>
  import { ref, reactive, onMounted} from 'vue'
  import { request } from "@/utils/request.js";
  import financialMoneyFzsr from '@/api/financial/financialMoneyFzsr'
  import preview from './preview.vue'
  import { Message } from '@arco-design/web-vue'
  import { useRouter } from 'vue-router'

  import tool from '@/utils/tool'
  import * as common from '@/utils/common'
  import { ElMapExportTable } from "table-excel";
  import timeFormat from "@/utils/timeFormat.js";
  const showJiesuan = ref(false)
  const showPreview = ref(false)
  const router = useRouter()
const fzzt = ref('0')
const xiaoji = ref(0)
const heji = ref(0)
const showMxiaojia = ref(0)
const rowData = ref({
    qsgs:'',
    skf:'',
    jsbl:'',
    beizhu:'',
    jssj:'',
})
const qsgsArr = ref([
  {value:'威斯腾',label:'威斯腾'},
])
const skfArr = ref([
  {value:'威斯腾',label:'威斯腾'},
])
const jiesuandata = ref([])
const optionsfzzt = ref([
    { label: '未分账', value: '0' },
    { label: '已分账', value: '1' },
])
const zffsArr = ref([
    {
        value: '1',
        label: '全部',
    },
    {
        value: '2',
        label: '预付款',
    },
    {
        value: '3',
        label: '周期结算',
    },
    {
        value: '4',
        label: '惠支付',
    },
    {
        value: '5',
        label: '现金',
    },
    {
        value: '6',
        label: '对公转账',
    },
])
const zffs = ref('1')
// 标签
// "今天", "昨天", "本周", "本月",'本季度','本年'
const tags = ref([
  {name:'今天',show:false},
  {name:'昨天',show:false},
  {name:'本周',show:false},
  {name:'本月',show:true},
  {name:'本季度',show:true},
  {name:'本年',show:true},
]);
// 当前标签
const currentTag = ref(3);
// 传入的时间
const currentTime = ref([]);
// 默认时间
// currentTime.value = [timeFormat(new Date().getTime(),'yyyy-mm-dd'),timeFormat(new Date().getTime(),'yyyy-mm-dd')]
// console.log('默认时间',currentTime.value)
// 当前时间
const newDate = new Date();
// 当年
const newYear = newDate.getFullYear();
// 当月
const newMonth = newDate.getMonth() + 1;
// 本季度开始月份
const newJDMonth = Math.ceil((newMonth) / 3);
// 今天
const newDay = newDate.getDate();
// 昨天
const oldDay = timeFormat(new Date(newDate).setDate(newDate.getDate() - 1),'yyyy-mm-dd');
// 本月天数
const newMaxDay = new Date(newYear, newMonth, 0).getDate();
// 本周一的日期
const newMonday = new Date(
  newDate.setDate(newDate.getDate() - newDate.getDay() + 1)
).getDate();
// 本周日的日期
const newSunday = new Date(newDate.setDate(newDate.getDate() + 6)).getDate();
const ids = ref([])
const crudRef = ref()
const crudRefs = ref()
const newmon = ref('')
const maxHeight = ref(0)
const boxRef = ref()
onMounted(()=>{
  maxHeight.value = boxRef.value.offsetHeight
})
const handlePreviewCel = ()=>{
  showPreview.value = false
}
const handleMonth = (e)=>{
  rowData.value.jssj = e
}
const handleRadioChange = (e)=>{
  crudRef.value.refresh()
}
const handleShowJiesuan = ()=>{
    if(ids.value.length == 0){
      return Message.error('请选择需要结算的账单')
    }
    financialMoneyFzsr.getidsList({ids:ids.value}).then(res=>{
      jiesuandata.value = res.data
      let arr = jiesuandata.value
      let munber = 0
      arr.map((v,i)=>{
        ids.value.map((vv,ii)=>{
          if(vv == v.id){
            munber += (v.pay_price - 0)
          }
        })
        
      })
      showMxiaojia.value = munber
      showJiesuan.value = true
    })
    
}
// 确认结算
const handleQuerenJS = async ()=>{
    if(rowData.value.qsgs == ''){
        Message.error("请选择付款方");
        return false
    }
    if(rowData.value.skf == ''){
        Message.error("请选择收款方");
        return false
    }
    if(rowData.value.jsbl == ''){
        Message.error("收款比例不能为空");
        return false
    }
    if(rowData.value.jssj == ''){
        Message.error("业务所属月份不能为空");
        return false
    }
    if(ids.value.length == 0){
        Message.error('请选择想要结算的订单')
        return false
    }
    let idarr = ids.value.join(',')
    let res = await financialMoneyFzsr.moneyFzSave({ids:idarr,qsgs:rowData.value.qsgs,skgs:rowData.value.skf,bili:rowData.value.jsbl,remark:rowData.value.beizhu,fz_date:rowData.value.jssj})
    if(res.code == 200){
      Message.success('结算成功！')
      ids.value = []
      showJiesuan.value = false
      rowData.value = {
          qsgs:'',
          skf:'',
          jsbl:'',
          beizhu:'',
          jssj:'',
      }
      crudRef.value.refresh()
      return true
    }else{
      Message.error(res.message)
      return false
    }
    
}

const itemData = ref([])


// 结算导出
const handleExports = ()=> {
      const instance = new ElMapExportTable(
        {
            column,
            data,
            spanMethod: ({ rowIndex, columnIndex }) => {
                // rowIndex 纵   columnIndex   横  rowspan 纵向合并  colspan横向合并
                return testFormData(itemData.value,rowIndex,columnIndex)
            },
            // setInsertHeader:()=>{
            //     return {
            //         cells: [
            //             {
            //                 row: 0,
            //                 col: 0,
            //                 rowspan: 1, // 占2行
            //                 colspan: 18, // 占3列
            //                 text: `基础物流汇总结算表${newmon.value}月`,
            //                 font: {
            //                         size: 32, // 字体大小
            //                         bold: true, // 字体加粗
            //                         italic: true, // 字体倾斜
            //                         color: { argb: "FFFF0000" }, // 字体颜色
            //                 },
                          
            //             },
            //         ],
            //     };
            // },
            setRowStyle({ data, columnIndex, rowIndex, type }) {
            if (type === "main") {
              return {
                height: 40,
              };
            }else{
              return {
                height: 40,
              };
            }
          },
        },
        // {progress: progress => console.log(progress)}
      );
      instance.download("基础物流汇总结算表" + newmon.value + '月');
}

// 结算数据
let data = []
// 选择月份
const handleExport = (e)=>{
  router.push('/financial/preview')
  // showPreview.value = true
  // let range_date = [];
  // let arr = e.split('-')
  // newmon.value = arr[1]
  // column[0].title = `基础物流汇总结算表${newmon.value}月`
  // let maxDay = new Date(arr[0], arr[1], 0).getDate()
  // range_date = [e + '-01 00:00:00',e + '-' + maxDay + ' 23:59:59']
  // handleExportData(range_date)
}
const handleExportData = (range_date) =>{
  request({
      url:'prediction/Tz/jiesuan',
      method: 'get',
      params:{
          range_date:range_date,
          qsgs:'威斯腾'
      },
  }).then(res=>{
      let _data = res.data
      let arr = []
      let objItem = {
        name:'总计',contract_str:'',spName:'',jfName:'',jfzongPrice:0,zong:1,bili:'',jsPrice:0,remark:'',
      }
      _data.map((v,i)=>{
        if(v.goods_type_list.length > v.charge_list.length){
          v.zong = v.goods_type_list.length
        }else{
          v.zong = v.charge_list.length
        }
      })
      
      _data.map((v,i)=>{
        if(v.goods_type_list.length > v.charge_list.length){
          v.goods_type_list.map((vv,ii)=>{
            let objItem = {
              name:v.name,
              contract_str:v.contract_str,
              spName:vv,
              jfName:v.charge_list[ii]?.name || '',
              jfzongPrice:v.charge_list[ii]?.price || 0,
              bili:'75%',
              jsPrice: ((v.charge_list[ii]?.price - 0) * 0.75) || '',
              remark:v.charge_list[ii]?.remark || ''
            }
            arr.push(objItem)
          })
        }else{
          v.charge_list.map((vv,ii)=>{
            let objItem = {
              name:v.name,
              contract_str:v.contract_str,
              spName:v?.goods_type_list[ii] || '',
              jfName:vv?.name || '',
              jfzongPrice:vv.price || 0,
              bili:'75%',
              jsPrice: ((vv.price - 0) * 0.75).toFixed(2) || '',
              remark:vv?.remark || ''
            }
            arr.push(objItem)
          })
        }
      })
      arr.map((v,i)=>{
        objItem.jfzongPrice += (v.jfzongPrice - 0)
        objItem.jsPrice += (v.jsPrice - 0)
      })
      _data.push(objItem)
      arr.push(objItem)
      arr.map((v,i)=>{
        v.jfzongPrice = (v.jfzongPrice - 0).toFixed(2) || ''
        v.jsPrice = (v.jsPrice - 0).toFixed(2) || ''
      })
      
      data = arr
      itemData.value = _data
      handleExports()
  })
}


const onChange = (e) => {
		currentTime.value = e
        crudRef.value.refresh()
	};
const handleChange = (e)=>{
    zffs.value = e
    crudRef.value.refresh()
}
const handleChangeqsgs = (e)=>{
    rowData.value.qsgs = e 
    
    rowData.value.jsbl = ''
    rowData.value.jssj = ''
    if(e == '威斯腾'){
        skfArr.value = [{value:'威斯腾',label:'威斯腾'}]
        rowData.value.skf = '威斯腾'
        rowData.value.jsbl = '75'
    }else{
        skfArr.value = [{value:'威斯腾',label:'威斯腾'}]
        rowData.value.skf = '威斯腾'
        rowData.value.jsbl = '25'
    }
}
const handleChangeskf = (e)=>{
    rowData.value.skf = e 
    if(e == '威斯腾'){
        rowData.value.jsbl = '25'
    }else{
        rowData.value.jsbl = '75'
    }
}
const changeTime = (index) => {
  currentTag.value = index;
  if (index !== tags.value.length) {
  	initTime(index);
    crudRef.value.refresh()
  	return;
  }
};
const setSelectedKeys = (val) => {
    ids.value = val
};
const setSelectedmodleKeys = (val) => {
    let arr = jiesuandata.value
    let munber = 0
    arr.map((v,i)=>{
      ids.value.map((vv,ii)=>{
        if(vv == v.id){
          munber += (v.pay_price - 0)
        }
      })
      
    })
    showMxiaojia.value = munber
	  // console.log(crudRefs.value.getTableData())
    // let arr = crudRefs.value.getTableData()
    // ids.value = val
    // let munber = 0
    // arr.map((v,i)=>{
    //   val.map((vv,ii)=>{
    //     if(vv == v.id){
    //       munber += (v.pay_price - 0)
    //     }
    //   })
      
    // })
    // showMxiaojia.value = munber
};
const handleYujiCel = ()=>{
    rowData.value = {
        qsgs:'',
        skf:'',
        jsbl:'',
        beizhu:'',
        jssj:'',
    }
    showJiesuan.value = false
}
const initTime = (index) => {
  switch (index) {
    // 默认 今日
    case 0:
      currentTime.value[0] = `${newYear}-${newMonth}-${newDay} 00:00:00`;
      currentTime.value[1] = `${newYear}-${newMonth}-${newDay} 23:59:59`;
      break;
    //昨日
    case 1:
      currentTime.value[0] = `${oldDay} 00:00:00`;
      currentTime.value[1] = `${oldDay} 23:59:59`;
      break;
    // 本周
    case 2:
      currentTime.value[0] = `${newYear}-${newMonth}-${newMonday} 00:00:00`;
      currentTime.value[1] = `${newYear}-${newMonth}-${newSunday} 23:59:59`;
      break;
    // 本月
    case 3:
      currentTime.value[0] = `${newYear}-${newMonth}-01 00:00:00`;
      currentTime.value[1] = `${newYear}-${newMonth}-${newMaxDay} 23:59:59`;
      break;
    // 本季度
    case 4:
      currentTime.value[0] = `${timeFormat(new Date(newYear, (newJDMonth-1)*3, 1),'yyyy-mm-dd')} 00:00:00`;
      currentTime.value[1] = `${timeFormat(new Date(newYear, newJDMonth*3, 0),'yyyy-mm-dd')} 23:59:59`;
      break;
    // 本年
    case 5:
      currentTime.value[0] = `${newYear}-01-01 00:00:00`;
      currentTime.value[1] = `${newYear}-12-31 23:59:59`;
      break;
  }
};
  const numberOperation = (newValue, id, numberName) => {
    financialMoneyFzsr.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
      res.success && Message.success(res.message)
    }).catch( e => { console.log(e) } )
  }
  
  const switchStatus = (statusValue, id, statusName) => {
    financialMoneyFzsr.changeStatus({ id, statusName, statusValue }).then( res => {
      res.success && Message.success(res.message)
    }).catch( e => { console.log(e) } )
  }
  const  spanMethodAll= ({record,rowIndex, columnIndex}) => {
    if (rowIndex === record.weizhi - record.weizhizong && columnIndex === 0) {
      return {rowspan: record.weizhizong,colspan:1}
    }
  };
  const handleSOrt = (ceshiArr)=>{
    let arr = []           // 最终数据
    let linshiArr = []     //  未匹配的放数组里
    let linshititle = ''   // 临时变量
    ceshiArr.map((v,i)=>{
      if(i == 0){
        linshititle = v.name
        arr.push(v)
      }else{
        if(linshititle == v.name){
          arr.push(v)
        }else{
          linshiArr.push(v)
        }
      }
    })
    ceshiArr.map((v,i)=>{
      if(linshiArr.length != 0){
        linshiArr.map((vv,ii)=>{
          if(ii == 0){
            linshititle = linshiArr[0].name
            arr.push(linshiArr.shift())
          }else{
            if(linshititle == vv.name){
              arr.push(linshiArr.slice(ii,1))
            }
          }
          
        })
        
      }
    })
    arr.sort((a, b) => a.car_nos.localeCompare(b.car_nos));
    return arr
  }
  const handleObjItem = (params)=>{
    params.map((v, i) => {
			let arr = []
      let arrs = []
      
      v.detail.map((vv,ii)=>{
        if(v.prediction_id){  //  到站收费
          vv.car_nos = vv.prediction.car_no
        }else{
          if(v.prediction_order_id != 0 && v.prediction_driver_order_id == 0){  //  补费
            vv.car_nos = ''
          }else{  // 装车收费
            if(vv.order_detail.prediction_id == 0){
              vv.car_nos = vv.order_detail.wareuserdetail.car_no
            }else{
              vv.car_nos = vv.order_detail.prediction.car_no
            }
          }
          
        }
        if(vv.pay_price != '0.00'){
          arr.push(vv)
        }
      })
      
      v.detail = handleSOrt(arr)
      
      let carArr = []
      v.detail.map((vv,ii)=>{
        carArr.push(vv.car_nos)
      })
      var newArr = carArr.filter(function(item,index){
        return carArr.indexOf(item) === index;  // 因为indexOf 只能查找到第一个  
      });
      let numArr = []
      newArr.map((vv,ii)=>{
        let num = 0
        let name = ''
        carArr.map((vvv,iii)=>{
          if(vv == vvv){
            num++
            name = vvv
          }
        })
        numArr.push({car_no:name,weizhi:num,weizhizong:num})
      })
      let weizhiArr = []
      let weizhinum = 0
      numArr.map((vv,ii)=>{
        weizhinum += vv.weizhi
        weizhiArr.push({car_no:vv.car_no,weizhi:weizhinum,weizhizong:vv.weizhizong})
      })
      v.detail.map((vv,ii)=>{
        weizhiArr.map((vvv,iii)=>{
          if(vv.car_nos == vvv.car_no){
            vv.weizhi = vvv.weizhi
            vv.weizhizong = vvv.weizhizong
          }
        })
      })
      
		});
    return params
  }


  const options = reactive({
    id: 'flyos_financial_money_fzsr',
    rowSelection: {
      showCheckedAll: true
    },
    pk: 'id',
    operationColumn: false,
    operationWidth: 160,
    formOption: {
      viewType: 'modal',
      width: 600
    },
    scroll:{y:'100%'},
    api: financialMoneyFzsr.getList,
    recycleApi: financialMoneyFzsr.getRecycleList,
    add: {
      show: false,
      api: financialMoneyFzsr.save,
      auth: ['financial:moneyFz:save']
    },
    edit: {
      show: false,
      api: financialMoneyFzsr.update,
      auth: ['financial:moneyFz:update']
    },
    delete: {
      show: false,
      api: financialMoneyFzsr.deletes,
      auth: ['financial:moneyFz:delete'],
      realApi: financialMoneyFzsr.realDeletes,
      realAuth: ['financial:moneyFz:realDeletes']
    },
    recovery: {
      show: false,
      api: financialMoneyFzsr.recoverys,
      auth: ['financial:moneyFz:recovery']
    },
    import: {
      show: false,
      url: 'financial/moneyFz/import',
      templateUrl: 'financial/moneyFz/downloadTemplate',
      auth: ['financial:moneyFz:import']
    },
    export: {
      show: false,
      url: 'financial/moneyFz/export',
      auth: ['financial:moneyFz:export']
    },
    afterSearch:(params) => {
      ids.value = []
    },
    beforeRequest: (params) => {
        if(zffs.value == 1){
            params.pay_type = ''
            params.now_pay_type = ''
        }else if(zffs.value == 2){
            params.pay_type = 'money'
            params.now_pay_type = ''
        }else if(zffs.value == 3){
            params.pay_type = 'periodic'
            params.now_pay_type = ''
        }else if(zffs.value == 4){
            params.pay_type = 'now_pay'
            params.now_pay_type = '1'
        }else if(zffs.value == 5){
            params.pay_type = 'now_pay'
            params.now_pay_type = '2'
        }else if(zffs.value == 6){
            params.pay_type = 'now_pay'
            params.now_pay_type = '3'
        }
        initTime(currentTag.value)
        // params.created_at = currentTime.value;
        params.is_fz = fzzt.value;
		
        params.pay_status = 1
        console.log('params:',params)
        request({
        url:'financial/payOrder/srfzTotal',
        method: 'get',
        params:params,
        }).then(res=>{
          heji.value = res.data.total
        })
        

    },
    afterRequest: (params) => {
      let number = 0
      handleObjItem(params)
      params.map((v, i) => {
        v.dept_name = v.dept.name;
        let arr=[]
        v.detail.map((vv,ii)=>{
          vv.car_nos = vv.prediction.car_no
          vv.no_tax_price = (vv.no_tax_price - 0 ).toFixed(2)
          vv.tax_price = (vv.tax_price - 0 ).toFixed(2)
          vv.pay_real_price = (vv.pay_real_price - 0 ).toFixed(2)
          vv.pay_price = (vv.pay_price - 0 ).toFixed(2)
          vv.discount_price = (vv.discount_price - 0 ).toFixed(2)
          if(vv.is_confirm == 1){
            arr.push(vv)
          }
        })
        v.detail = arr
        console.log(v.detail)
        number += (v.pay_price - 0)
        if(v.is_fz != 0){
          v.disabled = true
        }
      });
      xiaoji.value = number
    },
    
  })
  const optionses = reactive({
    id: 'flyos_financial_money_fzsr',
    rowSelection: {
      showCheckedAll: true
    },
    pk: 'id',
    showTools:false,
    tablePagination:false,
    operationColumn: false,
    operationWidth: 160,
    formOption: {
      viewType: 'modal',
      width: 600
    },
    api: financialMoneyFzsr.getidsList,
    add: {
      show: false,
      api: financialMoneyFzsr.save,
      auth: ['financial:moneyFz:save']
    },
    edit: {
      show: false,
      api: financialMoneyFzsr.update,
      auth: ['financial:moneyFz:update']
    },
    delete: {
      show: false,
      api: financialMoneyFzsr.deletes,
      auth: ['financial:moneyFz:delete'],
      realApi: financialMoneyFzsr.realDeletes,
      realAuth: ['financial:moneyFz:realDeletes']
    },
    recovery: {
      show: false,
      api: financialMoneyFzsr.recoverys,
      auth: ['financial:moneyFz:recovery']
    },
    import: {
      show: false,
      url: 'financial/moneyFz/import',
      templateUrl: 'financial/moneyFz/downloadTemplate',
      auth: ['financial:moneyFz:import']
    },
    export: {
      show: false,
      url: 'financial/moneyFz/export',
      auth: ['financial:moneyFz:export']
    },
    beforeRequest: (params) => {
        params.ids = ids.value;
	  },
    afterRequest: (params) => {
      let number = 0
      params.map((v, i) => {




        number += (v.pay_price - 0)
      });
      showMxiaojia.value = number
    },
  })
const tablecolumnsts = [
      {
        title: '车号',
        dataIndex: 'car_nos',
      },
      {
        title: '收费项目',
        dataIndex: 'pay_name',

      },
      {
          title: '不含税金额',
          dataIndex: 'no_tax_price',
      },
      {
          title: '税额',
          dataIndex: 'tax_price',
      },
      {
        title: '原金额',
        dataIndex: 'pay_price',
      },
      {
        title: '实际金额',
        dataIndex: 'pay_real_price',
      },
      {
          title: '优惠金额',
          dataIndex: 'discount_price',
      },
      {
        title: '天-D',
        dataIndex: 'day',
      },
      {
        title: '吨-T',
        dataIndex: 'weight',
      },
      {
        title: '车-C',
        dataIndex: 'car_no_value',
      },
      {
        title: '箱-X',
        dataIndex: 'box',
      },
      {
        title: '计费规则',
        dataIndex: 'chi_price_role',
      },
      {
        title: '备注',
        dataIndex: 'remark',
      },
];
  const columns = reactive([
    {
      title: "",
      dataIndex: "id",
      formType: "input",
      addDisplay: false,
      editDisplay: false,
      hide: true,
      commonRules: {
        required: true,
        message: "请输入"
      }
    },
    {
      title: "签署公司",
      dataIndex: "sign_dept",
      formType: "select",
      search: false,
      align:'center',
      dict: {
        data: [
          {value:'威斯腾',label:'威斯腾'},
        ],
        translation: true
      }
    },
    {
      title: "客户名称",
      dataIndex: "dept_id",
      formType: "select",
      search: true,
      align:'center',
      dict: {
        // 远程通用接口请求，新版代码生成都有一个 remote 接口
        remote: "system/dept/remote",
        // 指定组件接收的props
        props: { label: "name", value: "id" },
        // 开启分页
        openPage: false,
        // 远程请求配置项
        remoteOption: {
          // 按用户名排序
          sort: { id: "desc" }, // 如果不指定排序方式，默认为正序排序
          // 设置查询的字段
          select: ["id", "name"],
          // 设置数据过滤
          filter: {
            type: ["=", 2],
            status: ['=',1]
          },
          // 关联模型
          relations: [],
        },
      },
    },
    
    {
      title: "交易金额",
      dataIndex: "pay_price",
      formType: "input",
      search: false,
      align:'center'
    },
    {
      title: "支付方式",
      dataIndex: "pay_type",
      formType: "input",
      align:'center'
    },
    {
      title: "现结支付类型",
      dataIndex: "now_pay_type",
      formType: "input",
      align:'center'
    },
    {
      title: "交易时间",
      dataIndex: "pay_date",
      formType: "range",
      addDisplay: false,
      editDisplay: false,
      search: true,
      align:'center',
      showTime: true,
    },
    {
      title: "交易单号",
      dataIndex: "order_number",
      formType: "input",
      addDisplay: false,
      editDisplay: false,
      search: true,
      align:'center'
    },
    {
      title: "关联订单",
      dataIndex: "prediction_order_number",
      formType: "input",
      addDisplay: false,
      editDisplay: false,
      search: true,
      align:'center'
    },
  ])
  const columnses = reactive([
    {
      title: "签署公司",
      dataIndex: "sign_dept",
      align:'center',
      slotName:'sign_dept'
    },
    {
      title: "客户名称",
      dataIndex: "dept_id",
      formType: "input",
      search: false,
      align:'center',
      slotName:'dept_id'
    },
    
    {
      title: "交易金额",
      dataIndex: "pay_price",
      formType: "input",
      search: false,
      align:'center',
      slotName:'pay_price'
    },
    {
      title: "支付方式",
      dataIndex: "pay_type",
      align:'center',
      slotName:'pay_type'
    },
    {
      title: "现结支付类型",
      dataIndex: "now_pay_type",
      align:'center',
      slotName:'now_pay_type'
    },
    {
      title: "交易时间",
      dataIndex: "pay_date",
      align:'center',
      slotName:'pay_date'
    },
    {
      title: "交易单号",
      dataIndex: "order_number",
      align:'center',
      slotName:'order_number'
    },
    {
      title: "关联订单",
      dataIndex: "prediction_order_number",
      align:'center',
      slotName:'prediction_order_number'
    },
  ])
  </script>
  <style scoped lang="less">
  .home-page-title {
      align-items: center !important;

      img {
          height: 30px;
      }

      .datetime {
          align-items: center;

          p {
              font-size: 20px;
              color: #415b73;
              margin-left: 20px;
              font-style: italic;
          }

          span {
              width: 64px;
              border-radius: 32px;
              padding: 4px 0;
              display: flex;
              justify-content: center;
              align-items: center;
              margin-right: 20px;
              color: #00a0e9;
              border: 1px solid #00a0e9;
              font-size: 14px;
              font-weight: 400;
              cursor: pointer;

              &.active {
                  background: #00a0e9;
                  color: #fff;
              }
          }
      }
  }
</style>
  <script> export default { name: 'financial:moneySrfz' } </script>